<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>FabGL: VGA/Altair8800/Altair8800.ino</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">FabGL
   </div>
   <div id="projectbrief">ESP32 Display Controller and Graphics Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('_v_g_a_2_altair8800_2_altair8800_8ino-example.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">VGA/Altair8800/Altair8800.ino</div>  </div>
</div><!--header-->
<div class="contents">
<p>Altair 8800 Emulator - with ADM-31, ADM-3A, Kaypro, Hazeltine 1500 and Osborne I terminal emulation</p>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">  Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - &lt;http://www.fabgl.com&gt;</span></div><div class="line"><span class="comment">  Copyright (c) 2019-2021 Fabrizio Di Vittorio.</span></div><div class="line"><span class="comment">  All rights reserved.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">* Please contact fdivitto2013@gmail.com if you need a commercial license.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">* This library and related software is available under GPL v3.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  FabGL is free software: you can redistribute it and/or modify</span></div><div class="line"><span class="comment">  it under the terms of the GNU General Public License as published by</span></div><div class="line"><span class="comment">  the Free Software Foundation, either version 3 of the License, or</span></div><div class="line"><span class="comment">  (at your option) any later version.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  FabGL is distributed in the hope that it will be useful,</span></div><div class="line"><span class="comment">  but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div><div class="line"><span class="comment">  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span></div><div class="line"><span class="comment">  GNU General Public License for more details.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">  You should have received a copy of the GNU General Public License</span></div><div class="line"><span class="comment">  along with FabGL.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"> <span class="comment">/*</span></div><div class="line"><span class="comment">  * Optional SD Card connections:</span></div><div class="line"><span class="comment">  *   MISO =&gt; GPIO 16  (2 for PICO-D4)</span></div><div class="line"><span class="comment">  *   MOSI =&gt; GPIO 17  (12 for PICO-D4)</span></div><div class="line"><span class="comment">  *   CLK  =&gt; GPIO 14</span></div><div class="line"><span class="comment">  *   CS   =&gt; GPIO 13</span></div><div class="line"><span class="comment">  *</span></div><div class="line"><span class="comment">  * To change above assignment fill other paramaters of FileBrowser::mountSDCard().</span></div><div class="line"><span class="comment">  */</span></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;Preferences.h&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="fabgl_8h.html">fabgl.h</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="fabutils_8h.html">fabutils.h</a>&quot;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;src/machine.h&quot;</span></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// Flash and SDCard configuration</span></div><div class="line"><span class="preprocessor">#define FORMAT_ON_FAIL     true</span></div><div class="line"><span class="preprocessor">#define SPIFFS_MOUNT_PATH  &quot;/flash&quot;</span></div><div class="line"><span class="preprocessor">#define SDCARD_MOUNT_PATH  &quot;/SD&quot;</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// Display controller (textual or bitmapped)</span></div><div class="line"><span class="preprocessor">#define USE_TEXTUAL_DISPLAYCONTROLLER</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// 8&#39;&#39; disk images (338K)</span></div><div class="line"><span class="comment">// To use these disks you have to enable Disk_338K and disable MiniDisk_76K</span></div><div class="line"></div><div class="line"><span class="comment">// CP/M 2.2</span></div><div class="line"><span class="preprocessor">#include &quot;disks/CPM22/cpm22_dsk.h&quot;</span>          <span class="comment">// usage: &quot;#define DRIVE_A cpm22_dsk&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;disks/CPM22/games_dsk.h&quot;</span>          <span class="comment">// usage: &quot;#define DRIVE_B games_dsk&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;disks/CPM22/turbopascal3_dsk.h&quot;</span>   <span class="comment">// usage: &quot;#define DRIVE_B turbopascal3_dsk&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;disks/CPM22/wordstar3_dsk.h&quot;</span>      <span class="comment">// usage: &quot;#define DRIVE_B wordstar3_dsk&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;disks/CPM22/wordstar4_dsk.h&quot;</span>      <span class="comment">// usage: &quot;#define DRIVE_B wordstar4_dsk&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;disks/CPM22/multiplan_dsk.h&quot;</span>      <span class="comment">// usage: &quot;#define DRIVE_B multiplan_dsk&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;disks/CPM22/dbaseii_dsk.h&quot;</span>        <span class="comment">// usage: &quot;#define DRIVE_B dbaseii_dsk&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;disks/CPM22/BDSC_dsk.h&quot;</span>           <span class="comment">// usage: &quot;#define DRIVE_B BDSC_dsk&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;disks/CPM22/langs_dsk.h&quot;</span>          <span class="comment">// usage: &quot;#define DRIVE_B langs_dsk&quot;</span></div><div class="line"></div><div class="line"><span class="comment">// CP/M 1.4</span></div><div class="line"><span class="preprocessor">#include &quot;disks/CPM14/cpm141_dsk.h&quot;</span>         <span class="comment">// usage: &quot;#define DRIVE_A cpm141_dsk&quot;</span></div><div class="line"></div><div class="line"><span class="comment">// CP/M 3</span></div><div class="line"><span class="preprocessor">#include &quot;disks/CPM3/cpm3_disk1_dsk.h&quot;</span>      <span class="comment">// usage: &quot;#define DRIVE_A cpm3_disk1_dsk&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;disks/CPM3/cpm3_disk2_dsk.h&quot;</span>      <span class="comment">// usage: &quot;#define DRIVE_B cpm3_disk2_dsk&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;disks/CPM3/cpm3_build_dsk.h&quot;</span>      <span class="comment">// usage: &quot;#define DRIVE_B cpm3_build_dsk&quot;</span></div><div class="line"></div><div class="line"><span class="comment">// Altair DOS</span></div><div class="line"><span class="comment">//   MEMORY SIZE? [insert &quot;64&quot;]</span></div><div class="line"><span class="comment">//   INTERRUPTS? [press ENTER]</span></div><div class="line"><span class="comment">//   HIGHEST DISK NUMBER? [insert &quot;1&quot;]</span></div><div class="line"><span class="comment">//   HOW MANY DISK FILES? [insert &quot;4&quot;]</span></div><div class="line"><span class="comment">//   HOW MANY RANDOM FILES? [insert &quot;4&quot;]</span></div><div class="line"><span class="preprocessor">#include &quot;disks/AltairDOS/DOS_1_dsk.h&quot;</span>      <span class="comment">// usage: &quot;#define DRIVE_A DOS_1_dsk&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;disks/AltairDOS/DOS_2_dsk.h&quot;</span>      <span class="comment">// usage: &quot;#define DRIVE_A DOS_2_dsk&quot;</span></div><div class="line"></div><div class="line"><span class="comment">// Basic</span></div><div class="line"><span class="comment">//    MEMORY SIZE? [press ENTER]</span></div><div class="line"><span class="comment">//    LINEPRINTER? [insert &quot;C&quot;]</span></div><div class="line"><span class="comment">//    HIGHEST DISK NUMBER? [press ENTER]</span></div><div class="line"><span class="comment">//    HOW MANY FILES? [press ENTER]</span></div><div class="line"><span class="comment">//    HOW MANY RANDOM FILES? [press ENTER]</span></div><div class="line"><span class="preprocessor">#include &quot;disks/basic/basic5_dsk.h&quot;</span>         <span class="comment">// usage: &quot;#define DRIVE_A basic5_dsk&quot;</span></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// Mini disk images (76K)</span></div><div class="line"><span class="comment">// To use these disks you have to enable MiniDisk_76K and disable Disk_338K</span></div><div class="line"></div><div class="line"><span class="comment">// CP/M 2.2</span></div><div class="line"><span class="preprocessor">#include &quot;minidisks/CPM22/cpm22_disk1_minidsk.h&quot;</span>  <span class="comment">// usage: &quot;#define DRIVE_A cpm22_disk1_minidsk&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;minidisks/CPM22/cpm22_disk2_minidsk.h&quot;</span>  <span class="comment">// usage: &quot;#define DRIVE_B cpm22_disk2_minidsk&quot;</span></div><div class="line"></div><div class="line"><span class="comment">// Basic (need i8080 CPU)</span></div><div class="line"><span class="comment">//   MEMORY SIZE? [press ENTER]</span></div><div class="line"><span class="comment">//   LINEPRINTER? [insert &quot;C&quot;]</span></div><div class="line"><span class="comment">//   HIGHEST DISK NUMBER? [insert &quot;0&quot;]</span></div><div class="line"><span class="comment">//   HOW MANY FILES? [insert &quot;3&quot;]</span></div><div class="line"><span class="comment">//   HOW MANY RANDOM FILES? [insert &quot;2&quot;]</span></div><div class="line"><span class="preprocessor">#include &quot;minidisks/basic/basic300_5F_minidisk.h&quot;</span> <span class="comment">// usage: &quot;#define DRIVE_A basic300_5F_minidisk&quot;</span></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// Disks configuration</span></div><div class="line"></div><div class="line"><span class="comment">// Enable this when using 8&#39;&#39; disk images (&quot;disks&quot; folder)</span></div><div class="line"><span class="preprocessor">#define DISKFORMAT Disk_338K</span></div><div class="line"></div><div class="line"><span class="comment">// Enable this when using minidisk images (&quot;minidisk&quot; folder)</span></div><div class="line"><span class="comment">//#define DISKFORMAT MiniDisk_76K</span></div><div class="line"></div><div class="line"><span class="comment">// Specify which disk image or file name assign to drives</span></div><div class="line"><span class="preprocessor">#define DRIVE_A cpm22_dsk     // A: read only (or read/write using SD Card)</span></div><div class="line"><span class="preprocessor">#define DRIVE_B games_dsk     // B: read only (or read/write using SD Card)</span></div><div class="line"><span class="preprocessor">#define DRIVE_C &quot;diskC.dsk&quot;   // C: read/write (remember to FORMAT!!)</span></div><div class="line"><span class="preprocessor">#define DRIVE_D &quot;diskD.dsk&quot;   // D: read/write (remember to FORMAT!!)</span></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// consts</span></div><div class="line"></div><div class="line">constexpr <span class="keywordtype">int</span> DefaultCPU         = 1;   <span class="comment">// 0 = i8080, 1 = Z80</span></div><div class="line"></div><div class="line">constexpr <span class="keywordtype">int</span> DefaultTermIndex   = 2;   <span class="comment">// Default: &quot;ADM-31&quot;</span></div><div class="line">constexpr <span class="keywordtype">int</span> MaxTermIndex       = 7;   <span class="comment">// Max: &quot;Legacy ANSI&quot;</span></div><div class="line"></div><div class="line">constexpr <span class="keywordtype">int</span> DefaultKbdLayIndex = 2;   <span class="comment">// Default: &quot;UK&quot;</span></div><div class="line"></div><div class="line">constexpr <span class="keywordtype">int</span> DefaultRowsCount   = 0;   <span class="comment">// 0 = no limit (34 on the text terminal)</span></div><div class="line"></div><div class="line"><span class="keyword">const</span> <span class="keywordtype">char</span> * ColorsStr[]         = { <span class="stringliteral">&quot;Green/Black&quot;</span>,      <span class="stringliteral">&quot;Yellow/Black&quot;</span>,      <span class="stringliteral">&quot;White/Black&quot;</span>,      <span class="stringliteral">&quot;Black/White&quot;</span>,      <span class="stringliteral">&quot;Yellow/Blue&quot;</span>,       <span class="stringliteral">&quot;Black/Yellow&quot;</span> };</div><div class="line"><span class="keyword">const</span> <a name="a0"></a><a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#gab87bacfdad76e61b9412d7124be44c1c">Color</a> TextColors[]         = { <a name="a1"></a><a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1ca8e551a5ca49dca47dd8d5af7a04dd9ea">Color::BrightGreen</a>, <a name="a2"></a><a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1ca19153c6eb83006792aac10c7eddb1df6">Color::BrightYellow</a>, <a name="a3"></a><a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1ca3bec3eb0c8a4aab8e31a3a290493ab85">Color::BrightWhite</a>, <a name="a4"></a><a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1cac1e9bce8242f443c54c7405223d616cd">Color::Black</a>,       <a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1ca19153c6eb83006792aac10c7eddb1df6">Color::BrightYellow</a>, <a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1cac1e9bce8242f443c54c7405223d616cd">Color::Black</a> };</div><div class="line"><span class="keyword">const</span> <a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#gab87bacfdad76e61b9412d7124be44c1c">Color</a> BackColors[]         = { <a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1cac1e9bce8242f443c54c7405223d616cd">Color::Black</a>,       <a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1cac1e9bce8242f443c54c7405223d616cd">Color::Black</a>,        <a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1cac1e9bce8242f443c54c7405223d616cd">Color::Black</a>,       <a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1ca3bec3eb0c8a4aab8e31a3a290493ab85">Color::BrightWhite</a>, <a name="a5"></a><a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1caf5e09dd1da4088464f264b7a3118bff8">Color::Blue</a>,         <a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1ca19153c6eb83006792aac10c7eddb1df6">Color::BrightYellow</a> };</div><div class="line">constexpr <span class="keywordtype">int</span> DefaultColorsIndex = 0;   <span class="comment">// Default: Green/Black</span></div><div class="line">constexpr <span class="keywordtype">int</span> MaxColorsIndex     = 5;</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// globals</span></div><div class="line"></div><div class="line"><span class="preprocessor">#ifdef USE_TEXTUAL_DISPLAYCONTROLLER</span></div><div class="line"><a name="_a6"></a><a class="code" href="classfabgl_1_1_v_g_a_text_controller.html">fabgl::VGATextController</a> DisplayController;</div><div class="line"><span class="preprocessor">#else</span></div><div class="line"><a name="_a7"></a><a class="code" href="classfabgl_1_1_v_g_a_controller.html">fabgl::VGAController</a>     DisplayController;</div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"><a name="_a8"></a><a class="code" href="classfabgl_1_1_p_s2_controller.html">fabgl::PS2Controller</a>     PS2Controller;</div><div class="line"><a name="_a9"></a><a class="code" href="classfabgl_1_1_terminal.html">fabgl::Terminal</a>          Terminal;</div><div class="line"></div><div class="line">Machine              altair;</div><div class="line">Mits88Disk           diskDrive(&amp;altair, DISKFORMAT);</div><div class="line">SIO                  SIO0(&amp;altair, 0x00);</div><div class="line">SIO                  SIO1(&amp;altair, 0x10);</div><div class="line">SIO                  SIO2(&amp;altair, 0x12);</div><div class="line">Preferences          preferences;</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// base path (can be SPIFFS_MOUNT_PATH or SDCARD_MOUNT_PATH depending from what was successfully mounted first)</span></div><div class="line"><span class="keywordtype">char</span> <span class="keyword">const</span> * basepath = <span class="keyword">nullptr</span>;</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><a name="a10"></a><a class="code" href="group___enumerations_ga67edd9a04814c247a553dfde047e6f62.html#ga67edd9a04814c247a553dfde047e6f62">TermType</a> getTerminalEmu()</div><div class="line">{</div><div class="line">  <span class="keywordflow">return</span> (<a class="code" href="group___enumerations_ga67edd9a04814c247a553dfde047e6f62.html#ga67edd9a04814c247a553dfde047e6f62">TermType</a>) preferences.getInt(<span class="stringliteral">&quot;termEmu&quot;</span>, DefaultTermIndex);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> setupTerminalEmu()</div><div class="line">{</div><div class="line">  Terminal.<a name="a11"></a><a class="code" href="classfabgl_1_1_terminal_ae338b7372e1272a016ee97143d7351f8.html#ae338b7372e1272a016ee97143d7351f8">setTerminalType</a>(getTerminalEmu());</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// 0 = max</span></div><div class="line"><span class="keywordtype">int</span> getRowsCount()</div><div class="line">{</div><div class="line">  <span class="keywordflow">return</span> preferences.getInt(<span class="stringliteral">&quot;rowsCount&quot;</span>, DefaultRowsCount);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> setupRowsCount()</div><div class="line">{</div><div class="line">  <span class="keywordtype">int</span> rows = getRowsCount();</div><div class="line">  <span class="keywordflow">if</span> (rows &lt;= 0)</div><div class="line">    Terminal.<a name="a12"></a><a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[r&quot;</span>);             <span class="comment">// disable scrolling region</span></div><div class="line">  <span class="keywordflow">else</span></div><div class="line">    Terminal.printf(<span class="stringliteral">&quot;\e[1;%dr&quot;</span>, rows);  <span class="comment">// enable scrolling region (1..rows)</span></div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> getKbdLayoutIndex()</div><div class="line">{</div><div class="line">  <span class="keywordflow">return</span> preferences.getInt(<span class="stringliteral">&quot;kbdLay&quot;</span>, DefaultKbdLayIndex);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> setupKbdLayout()</div><div class="line">{</div><div class="line">  PS2Controller.<a name="a13"></a><a class="code" href="classfabgl_1_1_p_s2_controller_add3a17b29e9908b6e5cca6f52122119b.html#add3a17b29e9908b6e5cca6f52122119b">keyboard</a>()-&gt;<a name="a14"></a><a class="code" href="classfabgl_1_1_keyboard_aca97a7179d5358ec795485e15618b243.html#aca97a7179d5358ec795485e15618b243">setLayout</a>( SupportedLayouts::layouts()[getKbdLayoutIndex()] );</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">bool</span> getRealCPUSpeed()</div><div class="line">{</div><div class="line">  <span class="keywordflow">return</span> preferences.getBool(<span class="stringliteral">&quot;realSpeed&quot;</span>, <span class="keyword">false</span>);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> setupRealCPUSpeed()</div><div class="line">{</div><div class="line">  altair.setRealSpeed(getRealCPUSpeed());</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// 0 = 8080, 1 = Z80</span></div><div class="line"><span class="keywordtype">int</span> getCPU()</div><div class="line">{</div><div class="line">  <span class="keywordflow">return</span> preferences.getInt(<span class="stringliteral">&quot;CPU&quot;</span>, DefaultCPU);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">bool</span> getEmuCRT()</div><div class="line">{</div><div class="line">  <span class="keywordflow">return</span> preferences.getBool(<span class="stringliteral">&quot;emuCRT&quot;</span>, <span class="keyword">false</span>);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> getColorsIndex()</div><div class="line">{</div><div class="line">  <span class="keywordflow">return</span> preferences.getInt(<span class="stringliteral">&quot;colors&quot;</span>, DefaultColorsIndex);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> setupTerminalColors()</div><div class="line">{</div><div class="line">  <span class="keywordtype">int</span> colorsIndex = getColorsIndex();</div><div class="line">  Terminal.<a name="a15"></a><a class="code" href="classfabgl_1_1_terminal_afad23f091c4bb07a71963f5f7aa1831d.html#afad23f091c4bb07a71963f5f7aa1831d">setForegroundColor</a>(TextColors[colorsIndex]);</div><div class="line">  Terminal.<a name="a16"></a><a class="code" href="classfabgl_1_1_terminal_ae6f04360ccc33a519bdff509fd81df62.html#ae6f04360ccc33a519bdff509fd81df62">setBackgroundColor</a>(BackColors[colorsIndex]);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// shown pressing PAUSE</span></div><div class="line"><span class="keywordtype">void</span> emulator_menu()</div><div class="line">{</div><div class="line">  <span class="keywordtype">bool</span> resetRequired = <span class="keyword">false</span>;</div><div class="line">  <span class="keywordtype">bool</span> changedRowsCount = <span class="keyword">false</span>;</div><div class="line"></div><div class="line">  <span class="keywordflow">for</span> (<span class="keywordtype">bool</span> loop = <span class="keyword">true</span>; loop; ) {</div><div class="line"></div><div class="line">    diskDrive.flush();</div><div class="line"></div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_ae338b7372e1272a016ee97143d7351f8.html#ae338b7372e1272a016ee97143d7351f8">setTerminalType</a>(<a name="a17"></a><a class="code" href="group___enumerations_ga67edd9a04814c247a553dfde047e6f62.html#gga67edd9a04814c247a553dfde047e6f62aae8007304090df4db995e4bbea0704af">TermType::ANSILegacy</a>);</div><div class="line"></div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\r\n\n\e[97m\e[40m                            ** Emulator Menu **\e[K\r\n\e[K\n&quot;</span>);</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>( <span class="stringliteral">&quot;\e[93m Z \e[37m Reset\e[K\n\r&quot;</span>);</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>( <span class="stringliteral">&quot;\e[93m S \e[37m Send Disk to Serial\e[K\n\r&quot;</span>);</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>( <span class="stringliteral">&quot;\e[93m R \e[37m Get Disk from Serial\e[K\n\r&quot;</span>);</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>( <span class="stringliteral">&quot;\e[93m F \e[37m Format FileSystem\e[K\n\r&quot;</span>);</div><div class="line">    Terminal.printf(<span class="stringliteral">&quot;\e[93m U \e[37m CPU: \e[33m%s\e[K\n\r&quot;</span>, getCPU() == 1 ? <span class="stringliteral">&quot;Z80&quot;</span> : <span class="stringliteral">&quot;i8080&quot;</span>);</div><div class="line">    Terminal.printf(<span class="stringliteral">&quot;\e[93m P \e[37m Real CPU Speed: \e[33m%s\e[K\n\r&quot;</span>, getRealCPUSpeed() ? <span class="stringliteral">&quot;YES&quot;</span> : <span class="stringliteral">&quot;NO&quot;</span>);</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[6A&quot;</span>);  <span class="comment">// cursor UP</span></div><div class="line">    Terminal.printf(<span class="stringliteral">&quot;\t\t\t\t\t\e[93m T \e[37m Terminal: \e[33m%s\e[K\n\r&quot;</span>, SupportedTerminals::names()[(<span class="keywordtype">int</span>)getTerminalEmu()] );</div><div class="line">    Terminal.printf(<span class="stringliteral">&quot;\t\t\t\t\t\e[93m K \e[37m Keyboard Layout: \e[33m%s\e[K\n\r&quot;</span>, SupportedLayouts::names()[getKbdLayoutIndex()] );</div><div class="line"><span class="preprocessor">    #ifndef USE_TEXTUAL_DISPLAYCONTROLLER</span></div><div class="line">    Terminal.printf(<span class="stringliteral">&quot;\t\t\t\t\t\e[93m G \e[37m CRT Mode: \e[33m%s\e[K\n\r&quot;</span>, getEmuCRT() ? <span class="stringliteral">&quot;YES&quot;</span> : <span class="stringliteral">&quot;NO&quot;</span>);</div><div class="line"><span class="preprocessor">    #endif</span></div><div class="line">    Terminal.printf(<span class="stringliteral">&quot;\t\t\t\t\t\e[93m C \e[37m Colors: \e[33m%s\e[K\n\r&quot;</span>, ColorsStr[getColorsIndex()] );</div><div class="line">    Terminal.printf(<span class="stringliteral">&quot;\t\t\t\t\t\e[93m L \e[37m Rows: \e[33m%d\e[K\n\r&quot;</span>,  getRowsCount() &lt;= 0 ? Terminal.<a name="a18"></a><a class="code" href="classfabgl_1_1_terminal_a1bb8ac2a73a5d9e6256505e1bf51c6a9.html#a1bb8ac2a73a5d9e6256505e1bf51c6a9">getRows</a>() : getRowsCount());</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>( <span class="stringliteral">&quot;\t\t\t\t\t\e[93m O \e[37m Reset Configuration\e[K\n\r&quot;</span>);</div><div class="line"></div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\n\n\e[97mPlease select an option (ENTER to exit): \e[K\e[92m&quot;</span>);</div><div class="line">    <span class="keywordtype">int</span> ch = toupper(Terminal.<a name="a19"></a><a class="code" href="classfabgl_1_1_terminal_aaab5dab5b969a87f538242e524431637.html#aaab5dab5b969a87f538242e524431637">read</a>());</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(ch);</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\n\r&quot;</span>);</div><div class="line">    <span class="keywordflow">switch</span> (ch) {</div><div class="line"></div><div class="line">      <span class="comment">// 1. Send a disk image to Serial Port</span></div><div class="line">      <span class="comment">// 2. Receive a disk image from Serial Port</span></div><div class="line">      <span class="keywordflow">case</span> <span class="charliteral">&#39;S&#39;</span>:</div><div class="line">      <span class="keywordflow">case</span> <span class="charliteral">&#39;R&#39;</span>:</div><div class="line">      {</div><div class="line">        Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;Select a drive (A, B, C, D...): &quot;</span>);</div><div class="line">        <span class="keywordtype">char</span> drive = toupper(Terminal.<a class="code" href="classfabgl_1_1_terminal_aaab5dab5b969a87f538242e524431637.html#aaab5dab5b969a87f538242e524431637">read</a>());</div><div class="line">        <span class="keywordflow">if</span> (ch == <span class="charliteral">&#39;S&#39;</span>) {</div><div class="line">          Terminal.printf(<span class="stringliteral">&quot;\n\rSending drive %c...\n\r&quot;</span>, drive);</div><div class="line">          diskDrive.sendDiskImageToStream(drive - <span class="charliteral">&#39;A&#39;</span>, &amp;Serial);</div><div class="line">        } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ch == <span class="charliteral">&#39;R&#39;</span>) {</div><div class="line">          Terminal.printf(<span class="stringliteral">&quot;\n\rReceiving drive %c...\n\r&quot;</span>, drive);</div><div class="line">          diskDrive.receiveDiskImageFromStream(drive - <span class="charliteral">&#39;A&#39;</span>, &amp;Serial);</div><div class="line">        }</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line"></div><div class="line">      <span class="comment">// Format FileSystem</span></div><div class="line">      <span class="keywordflow">case</span> <span class="charliteral">&#39;F&#39;</span>:</div><div class="line">        Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[91mFormat deletes all disks and files in your SD or SPIFFS!\e[92m\r\nAre you sure? (Y/N)&quot;</span>);</div><div class="line">        <span class="keywordflow">if</span> (toupper(Terminal.<a class="code" href="classfabgl_1_1_terminal_aaab5dab5b969a87f538242e524431637.html#aaab5dab5b969a87f538242e524431637">read</a>()) == <span class="charliteral">&#39;Y&#39;</span>) {</div><div class="line">          Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\n\rFormatting...&quot;</span>);</div><div class="line">          Terminal.<a name="a20"></a><a class="code" href="classfabgl_1_1_terminal_af04a513134593e61c4575b266c8bf0ee.html#af04a513134593e61c4575b266c8bf0ee">flush</a>();</div><div class="line">          FileBrowser::format(FileBrowser::getDriveType(basepath), 0);</div><div class="line">          resetRequired = <span class="keyword">true</span>;</div><div class="line">        }</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">      <span class="comment">// Reset</span></div><div class="line">      <span class="keywordflow">case</span> <span class="charliteral">&#39;Z&#39;</span>:</div><div class="line">        Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;Resetting the Altair. Are you sure? (Y/N)&quot;</span>);</div><div class="line">        <span class="keywordflow">if</span> (toupper(Terminal.<a class="code" href="classfabgl_1_1_terminal_aaab5dab5b969a87f538242e524431637.html#aaab5dab5b969a87f538242e524431637">read</a>()) == <span class="charliteral">&#39;Y&#39;</span>)</div><div class="line">          ESP.restart();</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">      <span class="comment">// Real CPU speed</span></div><div class="line">      <span class="keywordflow">case</span> <span class="charliteral">&#39;P&#39;</span>:</div><div class="line">        preferences.putBool(<span class="stringliteral">&quot;realSpeed&quot;</span>, !getRealCPUSpeed());</div><div class="line">        setupRealCPUSpeed();</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">      <span class="comment">// Emulate CRT</span></div><div class="line">      <span class="keywordflow">case</span> <span class="charliteral">&#39;G&#39;</span>:</div><div class="line">        preferences.putBool(<span class="stringliteral">&quot;emuCRT&quot;</span>, !getEmuCRT());</div><div class="line">        resetRequired = <span class="keyword">true</span>;</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">      <span class="comment">// CPU</span></div><div class="line">      <span class="keywordflow">case</span> <span class="charliteral">&#39;U&#39;</span>:</div><div class="line">        preferences.putInt(<span class="stringliteral">&quot;CPU&quot;</span>, getCPU() ^ 1);</div><div class="line">        resetRequired = <span class="keyword">true</span>;</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">      <span class="comment">// Terminal emulation</span></div><div class="line">      <span class="keywordflow">case</span> <span class="charliteral">&#39;T&#39;</span>:</div><div class="line">      {</div><div class="line">        <span class="keywordtype">int</span> termIndex = (int)getTerminalEmu() + 1;</div><div class="line">        <span class="keywordflow">if</span> (termIndex &gt; MaxTermIndex)</div><div class="line">          termIndex = 0;</div><div class="line">        preferences.putInt(<span class="stringliteral">&quot;termEmu&quot;</span>, termIndex);</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line"></div><div class="line">      <span class="comment">// Keyboard layout</span></div><div class="line">      <span class="keywordflow">case</span> <span class="charliteral">&#39;K&#39;</span>:</div><div class="line">      {</div><div class="line">        <span class="keywordtype">int</span> kbdLayIndex = getKbdLayoutIndex() + 1;</div><div class="line">        <span class="keywordflow">if</span> (kbdLayIndex &gt;= SupportedLayouts::count())</div><div class="line">          kbdLayIndex = 0;</div><div class="line">        preferences.putInt(<span class="stringliteral">&quot;kbdLay&quot;</span>, kbdLayIndex);</div><div class="line">        setupKbdLayout();</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line"></div><div class="line">      <span class="comment">// Colors</span></div><div class="line">      <span class="keywordflow">case</span> <span class="charliteral">&#39;C&#39;</span>:</div><div class="line">      {</div><div class="line">        <span class="keywordtype">int</span> colorsIndex = getColorsIndex() + 1;</div><div class="line">        <span class="keywordflow">if</span> (colorsIndex &gt; MaxColorsIndex)</div><div class="line">          colorsIndex = 0;</div><div class="line">        preferences.putInt(<span class="stringliteral">&quot;colors&quot;</span>, colorsIndex);</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line"></div><div class="line">      <span class="comment">// Rows</span></div><div class="line">      <span class="keywordflow">case</span> <span class="charliteral">&#39;L&#39;</span>:</div><div class="line">      {</div><div class="line">        <span class="keywordtype">int</span> rows = getRowsCount() + 1;</div><div class="line">        <span class="keywordflow">if</span> (rows &lt; 24)</div><div class="line">          rows = 24;  <span class="comment">// min</span></div><div class="line">        <span class="keywordflow">if</span> (rows &gt; 25)</div><div class="line">          rows = 0;   <span class="comment">// max</span></div><div class="line">        preferences.putInt(<span class="stringliteral">&quot;rowsCount&quot;</span>, rows);</div><div class="line">        changedRowsCount = <span class="keyword">true</span>;</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">      }</div><div class="line"></div><div class="line">      <span class="comment">// Reset configuration</span></div><div class="line">      <span class="keywordflow">case</span> <span class="charliteral">&#39;O&#39;</span>:</div><div class="line">        preferences.clear();</div><div class="line">        resetRequired = <span class="keyword">true</span>;</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">      <span class="keywordflow">default</span>:</div><div class="line">        loop = <span class="keyword">false</span>;</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">    }</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (resetRequired) {</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;Reset required. Reset now? (Y/N)&quot;</span>);</div><div class="line">    <span class="keywordflow">if</span> (toupper(Terminal.<a class="code" href="classfabgl_1_1_terminal_aaab5dab5b969a87f538242e524431637.html#aaab5dab5b969a87f538242e524431637">read</a>()) == <span class="charliteral">&#39;Y&#39;</span>) {</div><div class="line">      diskDrive.detachAll();</div><div class="line">      ESP.restart();</div><div class="line">    }</div><div class="line">  }</div><div class="line"></div><div class="line">  Terminal.<a name="a21"></a><a class="code" href="classfabgl_1_1_terminal_a80440833b3e2b77b011b46da8529199f.html#a80440833b3e2b77b011b46da8529199f">localWrite</a>(<span class="stringliteral">&quot;\n&quot;</span>);</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (changedRowsCount) {</div><div class="line">    setupRowsCount();</div><div class="line">    Terminal.<a name="a22"></a><a class="code" href="classfabgl_1_1_terminal_a2da678d7453efcfed190b99ac93a53d0.html#a2da678d7453efcfed190b99ac93a53d0">clear</a>();</div><div class="line">    Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;Clear screen required. Settings applied.\r\n\e\n&quot;</span>);</div><div class="line">  }</div><div class="line"></div><div class="line">  setupTerminalColors();</div><div class="line">  setupTerminalEmu();</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> setup()</div><div class="line">{</div><div class="line">  preferences.begin(<span class="stringliteral">&quot;altair8800&quot;</span>, <span class="keyword">false</span>);</div><div class="line"></div><div class="line">  Serial.begin(115200);</div><div class="line"></div><div class="line">  <span class="comment">// setup Keyboard (default configuration)</span></div><div class="line">  PS2Controller.<a name="a23"></a><a class="code" href="classfabgl_1_1_p_s2_controller_ab8520612804a921ad834b41214a99c09.html#ab8520612804a921ad834b41214a99c09">begin</a>(PS2Preset::KeyboardPort0);</div><div class="line"></div><div class="line">  <span class="comment">// setup VGA (default configuration with 64 colors)</span></div><div class="line">  DisplayController.begin();</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (getEmuCRT())</div><div class="line">    DisplayController.<a name="a24"></a>setResolution(<a name="a25"></a><a class="code" href="fabglconf_8h_a7ad04e1bb6af1e841cf9785acf037e92.html#a7ad04e1bb6af1e841cf9785acf037e92">VGA_640x200_70HzRetro</a>);</div><div class="line">  <span class="keywordflow">else</span></div><div class="line">    DisplayController.setResolution(<a name="a26"></a><a class="code" href="fabglconf_8h_ac5e5d3057b7f87058c6191c87d9a1d54.html#ac5e5d3057b7f87058c6191c87d9a1d54">VGA_640x200_70Hz</a>);</div><div class="line"></div><div class="line">  Terminal.<a name="a27"></a><a class="code" href="classfabgl_1_1_terminal_aebaecc1fa474fddc48dd5778024b19a5.html#aebaecc1fa474fddc48dd5778024b19a5">begin</a>(&amp;DisplayController);</div><div class="line">  Terminal.<a name="a28"></a><a class="code" href="classfabgl_1_1_terminal_a068123b964647130439aa949370181dc.html#a068123b964647130439aa949370181dc">connectLocally</a>();      <span class="comment">// to use Terminal.read(), available(), etc..</span></div><div class="line"></div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_ae6f04360ccc33a519bdff509fd81df62.html#ae6f04360ccc33a519bdff509fd81df62">setBackgroundColor</a>(<a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1cac1e9bce8242f443c54c7405223d616cd">Color::Black</a>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_afad23f091c4bb07a71963f5f7aa1831d.html#afad23f091c4bb07a71963f5f7aa1831d">setForegroundColor</a>(<a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1ca8e551a5ca49dca47dd8d5af7a04dd9ea">Color::BrightGreen</a>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a2da678d7453efcfed190b99ac93a53d0.html#a2da678d7453efcfed190b99ac93a53d0">clear</a>();</div><div class="line"></div><div class="line">  Terminal.<a name="a29"></a><a class="code" href="classfabgl_1_1_terminal_aace245bfe6cab7b4339bd691077e1c23.html#aace245bfe6cab7b4339bd691077e1c23">enableCursor</a>(<span class="keyword">true</span>);</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> attachDisk(<span class="keywordtype">int</span> drive, <span class="keywordtype">void</span> <span class="keyword">const</span> * <a name="a30"></a><a class="code" href="displaycontroller_8h_a96db82e580e46e24e2b39dd6c5bf7c21.html#a96db82e580e46e24e2b39dd6c5bf7c21">data</a>)</div><div class="line">{</div><div class="line">  <span class="keyword">auto</span> filename = (<span class="keywordtype">char</span> <span class="keyword">const</span> *)<a class="code" href="displaycontroller_8h_a96db82e580e46e24e2b39dd6c5bf7c21.html#a96db82e580e46e24e2b39dd6c5bf7c21">data</a>;</div><div class="line">  <span class="keyword">auto</span> dskimage = (uint8_t <span class="keyword">const</span> *) <a class="code" href="displaycontroller_8h_a96db82e580e46e24e2b39dd6c5bf7c21.html#a96db82e580e46e24e2b39dd6c5bf7c21">data</a>;</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (dskimage[0] &gt;= 0x80) {</div><div class="line">    <span class="comment">// &quot;data&quot; is a disk image</span></div><div class="line">    <span class="keywordflow">if</span> (FileBrowser::getDriveType(basepath) == <a name="a31"></a><a class="code" href="group___enumerations_ga6c3316022eddc73875d854fcf43e61aa.html#gga6c3316022eddc73875d854fcf43e61aaa826ee4b27642806340fe4905532841e8">fabgl::DriveType::SDCard</a>) {</div><div class="line">      <span class="comment">// when storage is SD Card, copy read only disk image into a file, if doesn&#39;t already exist</span></div><div class="line">      <span class="keyword">auto</span> newfilename = String(basepath) + String(<span class="stringliteral">&quot;/disk&quot;</span>) + String((<span class="keywordtype">char</span>)(<span class="charliteral">&#39;A&#39;</span> + drive)) + String(<span class="stringliteral">&quot;.dsk&quot;</span>);</div><div class="line">      Terminal.printf(<span class="stringliteral">&quot;\r\nAttaching disk %c to %s...&quot;</span>, <span class="charliteral">&#39;A&#39;</span> + drive, newfilename.c_str());</div><div class="line">      diskDrive.attachFileFromImage(drive, newfilename.c_str(), dskimage);</div><div class="line">    } <span class="keywordflow">else</span> {</div><div class="line">      <span class="comment">// when storage is SPIFFS just mount image as Read Only image</span></div><div class="line">      diskDrive.attachReadOnlyBuffer(drive, dskimage);</div><div class="line">    }</div><div class="line">  } <span class="keywordflow">else</span> {</div><div class="line">    <span class="keywordflow">if</span> (filename[0] &lt; 0x80) {</div><div class="line">      <span class="comment">// &quot;data&quot; is a filename</span></div><div class="line">      Terminal.printf(<span class="stringliteral">&quot;\r\nAttaching disk %c to %s...&quot;</span>, <span class="charliteral">&#39;A&#39;</span> + drive, filename);</div><div class="line">      Terminal.<a class="code" href="classfabgl_1_1_terminal_af04a513134593e61c4575b266c8bf0ee.html#af04a513134593e61c4575b266c8bf0ee">flush</a>();</div><div class="line">      diskDrive.attachFile(drive, (String(basepath) + String(<span class="stringliteral">&quot;/&quot;</span>) + String(filename)).c_str());</div><div class="line">    }</div><div class="line">  }</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> loop()</div><div class="line">{</div><div class="line">  <span class="keywordflow">if</span> (FileBrowser::mountSDCard(FORMAT_ON_FAIL, SDCARD_MOUNT_PATH))</div><div class="line">    basepath = SDCARD_MOUNT_PATH;</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (FileBrowser::mountSPIFFS(FORMAT_ON_FAIL, SPIFFS_MOUNT_PATH))</div><div class="line">    basepath = SPIFFS_MOUNT_PATH;</div><div class="line"></div><div class="line">  <span class="comment">// setup disk drives</span></div><div class="line"></div><div class="line">  attachDisk(0, DRIVE_A);</div><div class="line">  attachDisk(1, DRIVE_B);</div><div class="line">  attachDisk(2, DRIVE_C);</div><div class="line">  attachDisk(3, DRIVE_D);</div><div class="line"></div><div class="line">  <span class="comment">// setup SIOs (Serial I/O)</span></div><div class="line"></div><div class="line">  <span class="comment">// TTY</span></div><div class="line">  SIO0.attachStream(&amp;Terminal);</div><div class="line"></div><div class="line">  <span class="comment">// CRT/Keyboard</span></div><div class="line">  SIO1.attachStream(&amp;Terminal);</div><div class="line"></div><div class="line">  <span class="comment">// Serial</span></div><div class="line">  SIO2.attachStream(&amp;Serial);</div><div class="line"></div><div class="line">  <span class="comment">// RAM</span></div><div class="line">  altair.attachRAM(65536);</div><div class="line"></div><div class="line">  <span class="comment">// boot ROM</span></div><div class="line">  altair.load(Altair88DiskBootROMAddr, Altair88DiskBootROM, <span class="keyword">sizeof</span>(Altair88DiskBootROM));</div><div class="line"></div><div class="line">  <span class="comment">// menu callback (pressing PAUSE or F12)</span></div><div class="line">  altair.setMenuCallback(emulator_menu);</div><div class="line"></div><div class="line">  setupTerminalColors();</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a2da678d7453efcfed190b99ac93a53d0.html#a2da678d7453efcfed190b99ac93a53d0">clear</a>();</div><div class="line"></div><div class="line">  setupRowsCount();</div><div class="line"></div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;\e[97m\e[44m&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;                    /* * * * * * * * * * * * * * * * * * * *\e[K\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;                             A L T A I R     8 8 0 0 \e[K\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;                     \e[37mby Fabrizio Di Vittorio - www.fabgl.com\e[97m\e[K\r\n&quot;</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_a7c66fc8d559f4956d4ccea196299bca7.html#a7c66fc8d559f4956d4ccea196299bca7">write</a>(<span class="stringliteral">&quot;                     * * * * * * * * * * * * * * * * * * * */\e[K\r\n\e[K\n&quot;</span>);</div><div class="line"></div><div class="line">  Terminal.printf(<span class="stringliteral">&quot;\e[33mFree Memory :\e[32m %d bytes\e[K\r\n&quot;</span>, heap_caps_get_free_size(MALLOC_CAP_32BIT));</div><div class="line"></div><div class="line">  int64_t total, used;</div><div class="line">  FileBrowser::getFSInfo(FileBrowser::getDriveType(basepath), 0, &amp;total, &amp;used);</div><div class="line">  Terminal.printf(<span class="stringliteral">&quot;\e[33mFile System :\e[32m %lld KiB used, %lld KiB free\e[K\r\n&quot;</span>, used / 1024, (total - used) / 1024);</div><div class="line"></div><div class="line">  Terminal.printf(<span class="stringliteral">&quot;\e[33mKbd Layout  : \e[32m%s\e[K\r\n&quot;</span>, SupportedLayouts::names()[getKbdLayoutIndex()] );</div><div class="line">  Terminal.printf(<span class="stringliteral">&quot;\e[33mCPU         : \e[32m%s\e[92m\e[K\r\n\e[K\n&quot;</span>, getCPU() == 1 ? <span class="stringliteral">&quot;Z80&quot;</span> : <span class="stringliteral">&quot;i8080&quot;</span>);</div><div class="line"></div><div class="line">  Terminal.printf(<span class="stringliteral">&quot;Press \e[93m[F12]\e[92m or \e[93m[PAUSE]\e[92m to display emulator menu\e[K\r\n&quot;</span>);</div><div class="line"></div><div class="line">  setupTerminalColors();</div><div class="line"></div><div class="line">  Terminal.<a name="a32"></a><a class="code" href="classfabgl_1_1_terminal_ae14dcf743cee53855ef05cc98b7a9e43.html#ae14dcf743cee53855ef05cc98b7a9e43">setColorForAttribute</a>(<a name="a33"></a><a class="code" href="displaycontroller_8h_ad03f06d4f3e36a9e80bd239d29fdb458.html#ad03f06d4f3e36a9e80bd239d29fdb458">CharStyle::Bold</a>, <a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1ca19153c6eb83006792aac10c7eddb1df6">Color::BrightYellow</a>, <span class="keyword">false</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_ae14dcf743cee53855ef05cc98b7a9e43.html#ae14dcf743cee53855ef05cc98b7a9e43">setColorForAttribute</a>(<a name="a34"></a><a class="code" href="displaycontroller_8h_a90ffbe895814fa7f76c80adfea9d8e95.html#a90ffbe895814fa7f76c80adfea9d8e95">CharStyle::Italic</a>, <a name="a35"></a><a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1ca2ed18d4ecd62410034c7ff19a1384357">Color::BrightRed</a>, <span class="keyword">false</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_ae14dcf743cee53855ef05cc98b7a9e43.html#ae14dcf743cee53855ef05cc98b7a9e43">setColorForAttribute</a>(<a name="a36"></a><a class="code" href="displaycontroller_8h_aa83a2188e3fe9edf5b07fd2fbe50b289.html#aa83a2188e3fe9edf5b07fd2fbe50b289">CharStyle::Underline</a>, <a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1ca3bec3eb0c8a4aab8e31a3a290493ab85">Color::BrightWhite</a>, <span class="keyword">false</span>);</div><div class="line">  Terminal.<a class="code" href="classfabgl_1_1_terminal_ae14dcf743cee53855ef05cc98b7a9e43.html#ae14dcf743cee53855ef05cc98b7a9e43">setColorForAttribute</a>(<a name="a37"></a><a class="code" href="group___enumerations_ga58734f6595a1eefb555afc0f1897fc3f.html#gga58734f6595a1eefb555afc0f1897fc3fa01a8eb7c512c56e42383b0564f4e1514">CharStyle::ReducedLuminosity</a>, <a class="code" href="group___enumerations_gab87bacfdad76e61b9412d7124be44c1c.html#ggab87bacfdad76e61b9412d7124be44c1ca19153c6eb83006792aac10c7eddb1df6">Color::BrightYellow</a>, <span class="keyword">false</span>);</div><div class="line"></div><div class="line">  <span class="comment">// setup keyboard layout</span></div><div class="line">  setupKbdLayout();</div><div class="line"></div><div class="line">  <span class="comment">// setup terminal emulation</span></div><div class="line">  setupTerminalEmu();</div><div class="line"></div><div class="line">  <span class="comment">// CPU speed</span></div><div class="line">  setupRealCPUSpeed();</div><div class="line"></div><div class="line">  CPU cpu = (getCPU() == 1 ? CPU::Z80 : CPU::i8080);</div><div class="line">  altair.run(cpu, Altair88DiskBootROMRun);</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Mon Aug 2 2021 07:08:02 for FabGL by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
